;; Sri Ganeshji : Sri Balaji : Sri Pitreshwarji : Sri Durgaji : Sri Venkateshwara
/*
Objective(s) -
-	This code demonstrates the COM Interface capability that has been introduced to call a function available in external DLL/EXE.
-	With this code, generic external DLLs can also be called to perform certain generic operations as programmed in the DLL.

Syntax -
-	[COM Interface: <COM Interface name>]
         Project	: <Name of the Project/ Namespace>
		 Class		: <Name of the Class>
		 Interface	: <Name of the function to be invoked>
		 Parameter	: <Parameter Name>		: <Data Type>[	: <Nature of Parameter>]
		 Returns	: <Data Type>
		 
		 where 
			Project accepts the name of the DLL Project or Namespace
			Class accepts the name of the Class within the DLL Project specified above
			Interface accepts the name of the Function within the Class specified under the Class attribute
			Parameter is a list type attribute where it accepts multiple parameters as required by the corresponding DLL Function
				and it accepts 3 parameter, viz., Parameter Name, Data Type of the Parameter and the Nature of Parameter which can be 
				In if the Parameter is only an Input to the DLL Function, Out if the Parameter is only an Output Parameter and
				InOut if the Parmaeter acts both as an Input as well as Output.
		 		 
-   Exec COM Interface: <COM Interface name> [: <Parameter 1> [: <Parameter 2> [:<Parameter N>]]]

		where
			COM Interface Name is the Name of the COM Interface defined as per the Syntax above.
			Parameter 1, 2, .... N are the optional Parameters accepted by the DLL Function being called
				and they must correspond to the Parameters declared, i.e., they must be in the same order declared in the COM Interface
				definition.  The Parameters can accept an expression provided it is not an Out or InOut Parameter.  If the Parameter is
				an Out or InOut Parameter, the variable name must only be specified i.e, without prefixing a ##.

Dependencies -
-	Supporting file 'MathLib.dll' must be registered in the system.

Last Modification -
-	Created on 25-4-2013
*/

[Report: TSPL Smp OutParminDivision]
	
	Form		: TSPL Smp OutParminDivision
	Title		: "Usage of 'Out' Parameter"
	Variable	: Remainder					: Number		;; This Variable is declared in Report Scope for Out Parameter
	
[Form: TSPL Smp OutParminDivision]
	
	Parts		: Form SubTitle, TSPL Smp OutParminDivision
	Local		: Field	: Form SubTitle		: Info		: "Division using COM DLL"
	No Confirm	: Yes
	Width		: 50% Page
	
[Part: TSPL Smp OutParminDivision]

	Lines		: TSPL Smp OutParminDivisionInput, TSPL Smp OutParminDivisionResult
	
	[Line: TSPL Smp OutParminDivisionInput]
		
		Fields		: Medium Prompt, TSPL Smp InParminAdditionInputDividend
		Right Fields: Long Prompt, TSPL Smp InParminAdditionInputDivisor

		Local		: Field	: Medium Prompt	: Info		: "Enter the Dividend :"
		Local		: Field	: Long Prompt	: Info		: "Divisor :"
		
		[Field: TSPL Smp InParminAdditionInputDividend]
			
			Use			: Number Field
			
		[Field: TSPL Smp InParminAdditionInputDivisor]
			
			Use			: Number Field
			Inactive	: $$IsEmpty:#TSPLSmpInParminAdditionInputDividend
			
	[Line: TSPL Smp OutParminDivisionResult]
		
		Fields		: Medium Prompt, TSPL Smp InParminAdditionResultQuotient
		Right Fields: Long Prompt, TSPL Smp InParminAdditionResultRemainder

		Local		: Field	: Medium Prompt	: Info		: "Quotient :"
		Local		: Field	: Long Prompt	: Info		: "Remainder (Returned from Out Parameter) :"
		
		[Field: TSPL Smp InParminAdditionResultQuotient]
			
			Use			: Number Field
			Inactive	: $$IsEmpty:#TSPLSmpInParminAdditionInputDividend OR $$IsEmpty:#TSPLSmpInParminAdditionInputDivisor
			Set as		: $$CalcQuotientandRemainderfromDLL:#TSPLSmpInParminAdditionInputDividend:#TSPLSmpInParminAdditionInputDivisor
;; Invoking a Function here as COMExecute cannot be used since Out Parameter is involved in the COM Interface

			Set Always	: Yes
			Read Only	: Yes 
			
		[Field: TSPL Smp InParminAdditionResultRemainder]
			
			Use			: Number Field
			Inactive	: $$IsEmpty:#TSPLSmpInParminAdditionInputDividend OR $$IsEmpty:#TSPLSmpInParminAdditionInputDivisor
			Set as		: ##Remainder
			Set Always	: Yes
			Read Only	: Yes

[Function: CalcQuotientandRemainderfromDLL]
	
	Parameter	: pDividend		: Number
	Parameter	: pDivisor		: Number
	
	Variable	: rQuotient		: Number
	
	00	: If	: NOT $$IsEmpty:##pDividend AND NOT $$IsEmpty:##pDivisor
	10	: 	Exec COM Interface	: TSPL Smp Division		: ##pDividend	: ##pDivisor	: Remainder	
	;; Remainder in Report Scope is passed as Out Parameter so that it can carry Parameter value back from DLL
	
	20	: 	Set		: rQuotient		: $$LastResult
	30	: 	Return	: ##rQuotient
	40	: End If
	
;; End-of-File